import 'package:native_dart_package/http/request/exception/api_exception.dart';
import 'package:yt_devops/configs.dart';
import 'package:yt_devops/services/predicates.dart';

class AlarmServices {
  /// 获取告警列表
  Future getAlarmsList(params) {
    return Configs.httpClient.get(
      '$oss/appAlarm/list',
      queryParameters: params,
    );
  }

  /// 获取各级告警数量
  Future getDiffAlarmNum(params) {
    return Configs.httpClient.get(
      '$oss/alarm/getAlarmNum',
      queryParameters: params,
    );
  }
  /// 获取告警列表20240320
  Future getAlarmsListNew(params, {bool Function(ApiException)? onError}) {
    return Configs.httpClient.get(
      '$oss/alarm/getAlarm',
      queryParameters: params,
        onError: onError
    );
  }

  /// 获取各级告警数量 20240320
  Future getDiffAlarmNumNew(params) {
    return Configs.httpClient.get(
      '$oss/alarm/getAlarmNum',
      queryParameters: params,
    );
  }
  /// 清除告警
  Future clearAlarm(params) {
    return Configs.httpClient.put(
      '$oss/appAlarm/clear',
      queryParameters: params,
    );
  }

  /// 确认单条告警
  Future confirmSingleAlarm(params) {
    return Configs.httpClient.put(
      '$oss/appAlarm/confirm',
      queryParameters: params,
    );
  }

  /// 确认多条告警
  Future confirmMultipleAlarm(params) {
    return Configs.httpClient.put(
      '$oss/appAlarm/confirm',
      queryParameters: params,
    );
  }

  /// 清除多条告警
  Future clearMultipleAlarm(params) {
    return Configs.httpClient.put(
      '$oss/appAlarm/clear',
      queryParameters: params,
    );
  }

  /// 获取告警详情
  Future getAlarmDetail(params) {
    return Configs.httpClient.get(
      '$oss/appAlarm/detail',
      queryParameters: params,
    );
  }
  ///获取设备下面子设备

  Future getSubDevice(param, {bool Function(ApiException)? onError}) {
    return Configs.httpClient.get(
        '$iot/es/deviceTree',
        queryParameters: param,
        onError: onError);
  }
}
